<?php
class wj_users extends Model
{
	// table columns definition
	//! @var id int PRIMARY KEY Sequense name: wj_users_id_seq
	protected $_id;
	//! @var pass string 
	protected $_pass;
	//! @var race int 
	protected $_race;
	//! @var sex int 
	protected $_sex;
	//! @var name string 
	protected $_name;
	//! @var status int 
	protected $_status;
	//! @var is_bot int 
	protected $_is_bot;
	//! @var block_reason string 
	protected $_block_reason;
	//! @var uid string 
	protected $_uid;
	//! @var origin int 
	protected $_origin;
	//! @var dt_login int 
	protected $_dt_login;
	//! @var dt_reg int 
	protected $_dt_reg;
	//! @var referal_id int 
	protected $_referal_id;
	//! @var dir int 
	protected $_dir;
	//! @var root_dir int 
	protected $_root_dir;

	// Название Primary Key
	public static $__pKey = Array("id");
	// Название Сиквеносв для полей
	public static $__key_pk_seq = Array("id" => "wj_users_id_seq");
	// Ключь для кеша
	public static $__cached_table = false;
	// Использует запрос на Many Кешь
	public static $__cache_many = true;
	// Поля таблицы и их типы
	public static $__fields = Array(
		 "id" => "int", 
		 "pass" => "string", 
		 "race" => "int", 
		 "sex" => "int", 
		 "name" => "string", 
		 "status" => "int", 
		 "is_bot" => "int", 
		 "block_reason" => "string", 
		 "uid" => "string", 
		 "origin" => "int", 
		 "dt_login" => "int", 
		 "dt_reg" => "int", 
		 "referal_id" => "int",
		 "dir" => "int",
		 "root_dir" => "int"
	);
	// setters
	
	protected function set_id($value)
	{
		 if(!$this->__initialized)
		 {
		 	$this->_id = $value; 
		 }else{
		 	throw new Exception("Property id is pkey and does not avaible for set in class ".get_class($this));
		 }
	}
 
    
    // Пользователь только для чтения
    protected $_readonly = 0;
    protected function get_readonly()
    {
        return $this->_readonly;
    }
    protected function set_readonly($value)
    {
        $this->_readonly = $value;
        return $this->_readonly;
    }
 
 
 	// Папки пользователя
 	protected $_folders;
 	protected function get_folders()
 	{
 		if ($this->_folders == null)
 		{ 			
 			$query = new Query();
 			$query->field("user_id", $this->id);
            $query->field("parent_id", $this->dir);
			$this->_folders = Worker::fetchManyObject(wj_folders, $query, "id");
 		}
 		return $this->_folders;
	}
    
    
 	
}

?>
